<!DOCTYPE html>
<html lang="en">
<head>
    <title>销售目标</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link href="/dist/plugins/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"/>
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=4a6c1b54">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style>
        .moduleName {
            float: left;
            height: 27px;
            line-height: 27px;
            font-size: 22px;
            text-align: left;
        }

        .tryStyle {
            width: 30px;
            height: 14px;
            line-height: 14px;
            font-size: 12px;
            /* top: 0; */
            right: 0;
            position: absolute;
            border-radius: 5px;
            margin-top: 1px;
            background: red;
            color: #fff;
            margin-right: -2px;
            transform: scale(0.8);
        }

        .nav-tabs-custom {
            padding: 10px;
            margin-bottom: 0;
            box-shadow: none;
            position: relative;
            overflow: hidden;
        }

        .infoReport {
            display: flex;
            justify-content: flex-start;
            text-align: left;
            margin-left: 10px;
        }

        .infoReport div {
            margin: 0 10px;
        }

        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .lineOneNoMore {
            text-align: left;
        }

        .lineOneNoMore span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .mScrollBox {
            float: left;
            position: relative;
        }

        .imgStyle {
            width: 300px;
            height: 400px;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }

        .templateStyle {
            border: 1px solid #ddd;
            margin-bottom: 10px;
            padding-bottom: 10px;
        }

        .table > thead > tr > th {
            padding: 0;
        }

        .table > tbody > tr > td {
            position: relative;
        }
        table{
            margin-bottom: 0 !important;
        }
        .td-tanZongStyle-line input {
            height: 24px !important;
            box-shadow: inset 1px 1px 4px #333;
            padding-left: 4px !important;
            width:100%;
        }
        .td-tanZongStyle-line span {
            padding-left: 4px !important;
        }
    </style>
</head>
<body>
<section class="content iframeH" id="app" v-cloak="">
    <iframe id="ifExprot" style="width:0px;height:0px;display: none;" frameborder="0"></iframe>
    <div class="div-td-content-more"><i></i></div>
    <div class="nav-tabs-custom oaReportNav">
        <div class="moduleName" >滚滚向前集团2019年销售目标</div>
        <ul class="nav nav-tabs pull-right" style="margin-bottom: 10px;"></ul></div>
    <div style="padding: 0px 10px; background: rgb(255, 255, 255);">
        <table  class="table  table-bordered text-center " style="width: 300px;">
            <thead>
            <tr>
                <th style="width: 100px;" rowspan="2">公司</th>
                <th style="width: 100px;" colspan="2">全年</th>
            </tr>
            <tr>
                <th style="width: 50px;">中大</th>
                <th style="width: 50px;">小</th>
            </tr>
            </thead>
            <tbody id="tbList">
                <tr v-for="(item,i) in list.info">
                    <!--<td>{{item.name}}</td>-->
                    <td><span style="color:#2a8cec;cursor: pointer;" @click="goDetail('look',i)">{{item.name}}</span></td>
                    <td class="td-tanZongStyle-line">
                        <input type="text" v-model="item.bigTargetNum" v-if="currentUser.id == '201711271733404C9DA1461F2421F828' &&  (!list.main || list.main.auditFlag == '2')" @blur="get_All()">
                        <span v-else>{{item.bigTargetNum}}</span>
                    </td>
                    <td class="td-tanZongStyle-line" >
                        <input type="text" v-model="item.smallTargetNum" v-if="currentUser.id == '201711271733404C9DA1461F2421F828' &&  (!list.main || list.main.auditFlag == '2')" @blur="get_All()">
                        <span v-else>{{item.smallTargetNum}}</span>
                    </td>
                </tr>
                <tr>
                    <td>合计</td>
                    <td>{{all.bigTargetNum}}</td>
                    <td>{{all.smallTargetNum}}</td>
                </tr>
            </tbody>
        </table>
        <table  class="table  table-bordered text-center " style="width: 300px;margin-top: 20px;" v-for="(item,i) in list.auditors">
            <tr>
                <td class=" td-module" colspan="2" style="background: yellow;">审批进度</td>
            </tr>
            <tr>
                <td class="td-title" style="width:17%;">审核人员</td>
                <td>
                    {{item.roleName}}-{{item.auditorName}}
                </td>
            </tr>
            <tr>
                <td class="td-title" style="width:16%;">审核状态</td>
                <td>
                    <span v-if="item.auditFlag==0" style="color:red;">{{convertAuditFlagToName(item.auditFlag)}}</span>
                    <span v-else>{{convertAuditFlagToName(item.auditFlag)}}</span>
                </td>
            </tr>
            <tr>
                <td class="td-title" style="width:17%;">审核时间</td>
                <td>{{item.auditTime}}</td>
            </tr>
            <tr>
                <td class="td-title">审核意见</td>
                <td>{{item.auditAdvise}}</td>
            </tr>
        </table>
    </div>
    <div class="south no-print" style="height:50px;line-height:50px;text-align:left;">
        <template v-if="list.main">
            <template v-if="currentUser.id == list.main.currentAuditorId && list.main.auditFlag == '0'">
                <input type="button" style="margin-left:70px;" value="通过"
                       class="btn oaBtn btn-sm"
                       @click="applyAudit('1')">
                <input type="button" style="margin-left:20px;" value="驳回"
                       class="btn oaBtn btn-sm"
                       @click="copierReturn">
            </template>
            <template v-else-if="currentUser.id == '201711271733404C9DA1461F2421F828' && list.main.auditFlag == '2'">
                <input type="button" style="margin-left:120px;" value="提交"
                       class="btn btn-primary btn-sm"
                       @click="save()">
            </template>
            <template v-else>

            </template>
        </template>
        <template v-else>
            <input type="button" style="margin-left:120px;" value="提交"
                   class="btn btn-primary btn-sm"
                   @click="save()">
        </template>
    </div>
</section>
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=8e743a31"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=54c6b89c"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript">
    function refresh() {

    }
    var app = new Vue({
        el: '#app',
        data: {
            id: $.wyui.page.urlParams.id ? $.wyui.page.urlParams.id : '',
            list:{
                info:[],
                main:{
                    id:$.wyui.page.urlParams.id,
                    year:'2019'
                },
                auditors:[]
            },
            all:{'bigTargetNum':0,'smallTargetNum':0},
            main:{
                id:$.wyui.page.urlParams.id ? $.wyui.page.urlParams.id : '',
                provinceId:'0',
                type:'0',
                year:'2019',
                auditFlag:'0',
                currentAuditorId:'',
                currentAuditorName:'',
                createUserId:getCurrentUser().id
            },
            currentUser: getCurrentUser(),
            dateTime: '2019',
//            pageType: ''
        },
        methods: {
            //获取合计
            getCount: function (arr, key) {
                var number = 0;
                for (var i = arr.length - 1; i >= 0; i--) {
                    number += (arr[i][key]&&arr[i][key]!=''? Number(arr[i][key]) : 0)
                }
                console.log(number)
                return number;
            },
            //跳转页  编辑和查看
            goDetail: function (type, i, isAdd) {
                var that = this;
                var companyId = that.list.info[i].id;
                console.log(companyId)
                var condition = '?companyId=' + companyId;
                condition += '&pageType=' + type;
                    top.closeTabByPageId("saleTargetProvince");
                    top.addTabs({
                        id: 'saleTargetProvince',
                        title: '公司目标配置',
                        close: true,
                        url: 'intentionManagement/saleTargetProvince.html' + condition
                    });
            },
            save:function () {
                var that = this;
                    $.wyui.postMethod(urlConfig.groupSaleTarget.save,
                        trimRN({main:that.main,list:that.list.info}),
                        function (data) {
                            alert('提交成功');
                            top.refreshTabByName("集团目标配置", "no");
                        })
            },
            convertAuditFlagToName: function (auditFlag) {
                //auditFlag:-1,0,1,2,3,4,5,6
                switch (auditFlag) {
                    case "-1":
                        return "未提交";
                        break;
                    case "0":
                        return "审核中";
                        break;
                    case "1":
                        return "通过";
                        break;
                    case "2":
                        return "驳回";
                        break;
                    default :
                        break;
                }
            },
            applyAudit: function (auditFlag) {
                if (auditFlag == "2") {

                } else {
                    if (!confirm("确定要通过吗？")) {
                        return;
                    }
                }
                var that = this;
                var advise = '';
//                for (var i = 0; i < this.list.main.auditors.length; i++) {
//                    if (this.repo.auditors[i].auditorId == this.currentUser.id) {
//                        advise = this.repo.auditors[i].auditAdvise;
//                        break;
//                    }
//                }
                if (auditFlag == '2' && advise == '') {
                    alert('请填写审核意见');
                    return;
                }
                if (advise == "") {
                    advise = "同意！";
                }
                $.wyui.postMethod(urlConfig.groupSaleTarget.applyAudit, {
                    id: that.list.main.id,
                    userId: getCurrentUser().id,
                    userName:getCurrentUser().name,
                    roleName:getCurrentUser().roleName,
                    auditFlag: auditFlag,
                    advise: advise
                }, function () {
                    alert("审核成功");
                    top.refreshTabByName("集团目标配置", "no");
                });
            },
            copierReturn: function () {
                var that = this;
                top.$.dialog({
                    content: 'url:/page/intentionManagement/saleTargetCopierReturnReason.html?id='
                    + that.list.main.id + "&pageType=saleTarget" + "&t=" + new Date(),
                    title: '填写驳回原因',
                    width: 300,
                    height: 200,
                    max: false,
                    min: false,
                    lock: true
                });
            },
            //获取列表
            get_list: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.groupSaleTarget.getGroupSaleByDateTime, {
                    "dateTime": that.dateTime
                }, function (data) {
                    console.log(data.info)
                    that.list= data;
                    that.all.bigTargetNum = that.getCount(data.info, "bigTargetNum");
                    that.all.smallTargetNum = that.getCount(data.info, "smallTargetNum");
                });
            },
            get_All:function (e,type,item) {
                var that=this;
                that.all.bigTargetNum = that.getCount(that.list.info, "bigTargetNum");
                that.all.smallTargetNum = that.getCount(that.list.info, "smallTargetNum");
            }
        },

        mounted: function () {
            var that = this;
            that.get_list();
        }
    });

</script>
</body>